package com;

import com.alibaba.druid.pool.DruidDataSource;
import com.alibaba.druid.pool.DruidPooledConnection;

import java.sql.SQLException;

public class Demo03Druid {



    public static void main(String[] args) throws SQLException {
        DruidDataSource dataSource = new DruidDataSource();
        dataSource.setDriverClassName("com.mysql.jdbc.Driver");
        dataSource.setUrl("jdbc:mysql://125.74.233.192:3306/fruitdb??characterEncoding=utf-8&rewriteBatchedStatements=true&useSSL=false");
        dataSource.setUsername("root");
        dataSource.setPassword("123456");
        // 设置数据源的初始大小
        dataSource.setInitialSize(2);
//        设置数据源的最大活动连接数为5
        dataSource.setMaxActive(5);
        dataSource.setMaxWait(5000);
        for (int i = 0; i < 10; i++) {
            DruidPooledConnection connection = dataSource.getConnection();
            System.out.println("connection = " + i +"---"+connection);
        }


    }
}
